package com.cxc.mp.simple.handle;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        Object password = this.getFieldValByName("password", metaObject);

        if(StringUtils.isEmpty(password)){//密码为空的时候可以自动填充
            setFieldValByName("password","888888",metaObject);
        }


    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
